package com.tsmti.core.util;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

/**
 * Title：PimsSystem
 * Class：com.tsmti.core.util.WebUtils
 * Comapny:
 *
 * @author：zcw
 * @version：2.5 CreateTime：2018/1/16 14:57
 * Modify log:
 * Description：
 * WebUtils类
 */
public class WebUtils {

    /**
     * 判断请求是否是ajax请求
     * @param request
     * @return
     */
    public static boolean isAjax(HttpServletRequest request){
        String accept = request.getHeader("accept");
        boolean isAjax = accept != null && accept.indexOf("application/json") > -1 || (request.getHeader("X-Requested-With") != null && request.getHeader("X-Requested-With").indexOf("XMLHttpRequest") > -1);
        return isAjax;
    }
}
